﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Setup
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            Logic.MainForm = this;
            InitializeComponent();
            if (Logic.Type == OperationType.Update)
                UpdateExe();
        }


        /// <summary>
        /// 更新
        /// </summary>
        public void UpdateExe()
        {
            if (Logic.Type != OperationType.Update)
            {
                Logic.Type = OperationType.Update;
                InstallInfo info = Logic.DefaultInstallInfo();

                if (info == null)
                {
                    MessageBox.Show("没有适用与当前操作系统的最新安装包");
                    return;
                }
                Logic.Install.Files = info.Files;
            }
            this.selectPath1.Visible = false;
            this.welcome1.Visible = false;
            this.progress1.Exec();
        }

        /// <summary>
        /// 卸载
        /// </summary>
        public void UnInstall()
        {
            Logic.Type = OperationType.UnInstall;
            this.selectPath1.Visible = false;
            this.welcome1.Visible = false;
            this.progress1.Exec();
        }

        /// <summary>
        /// 安装
        /// </summary>
        public void Install()
        {
            this.welcome1.Visible = false;
            Logic.Type = OperationType.Install;
        }

        /// <summary>
        /// 取消
        /// </summary>
        public void Cancel()
        {
            this.Close();
        }

        /// <summary>
        /// 下一步
        /// </summary>
        public void Next()
        {
            this.selectPath1.Visible = false;
            this.progress1.Exec();
        }

        /// <summary>
        /// 上一步
        /// </summary>
        public void Up()
        {
            
        }

        /// <summary>
        /// 完成
        /// </summary>
        public void Complete()
        {
            this.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (Logic.Install != null)
                this.Text = Logic.Install.DisplayName;
        }


    }
}
